//
//  Message.h
//  Message
//
//  Created by Dante Palacios on 30/08/09.
//  Copyright 2009 Dante Palacios. All rights reserved.
//

/*!
 @header Message.h
 @abstract The methods listed here may disappear or change their names without prior notice. For more information, contact palacios.dante\@gmail.com.
*/

#import <Foundation/Foundation.h>
#import <MailDelivery/Part.h>
#import <MailDelivery/MessageAddressee.h>


/*!
 @enum MessagePriority
 @discussion Constants the represent the message priority.
 @constant MessagePriorityHigh High priority.
 @constant MessagePriorityNormal Normal priority. This is the default value.
 @constant MessagePriorityLow Low priority.
 */

enum {
	MessagePriorityHigh = 1,
	MessagePriorityNormal = 3,
	MessagePriorityLow = 5,
};

/*!
 @class Message
 @abstract Class that represents an email message.
 @discussion <tt>Message</tt> is a subclass of class <tt>Part<tt> the represents an email message.
*/

@interface Message : Part {
@private;
	id /*<MessageAddressee>*/ _sender;
	id _representedObject;
	
	NSString *_subject;
	NSString *_identifier;
	NSString *_source;
	NSArray *_replyTo;
	NSArray *_parts;
	NSArray *_attachments;
	NSArray *_toRecipients;
	NSArray *_ccRecipients;
	NSArray *_bccRecipients;
	NSArray *_recipients;
	NSDate *_creationDate;
	NSDate *_dateSent;
	NSStringEncoding _encoding;
	NSInteger _priority;
}

/*!
 @method initWithHeaders:content:format:
 @discussion If message format is diferent from <tt><i>kMultipartAlternativeMessageFormat</i></tt> any rich text or attachments will be lost.
 @param messageHeaders
 contains all of the values that will appear in the message header.
 @param messageBody
 the contents of the message.
 @param messageFormat
 the format of the message. Can be <tt><i>kPlainTextMessageFormat</i></tt>, <tt><i>kHTMLMessageFormat</i></tt> or <tt><i>kMultipartAlternativeMessageFormat</i></tt>. 
 */

- (id)initWithHeaders:(NSDictionary *)messageHeaders content:(NSAttributedString *)messageBody format:(NSString *)messageFormat;

/*!
 @method initWithHeaders:content: 
 @abstract As in @link initWithHeaders:content:format: initWithHeaders:content:format: @/link, but passing kMultipartAlternativeMessageFormat as message format.
 */

- (id)initWithHeaders:(NSDictionary *)messageHeaders content:(NSAttributedString *)messageBody;

/*!
 @property representedObject
 @abstract can be anything or nothing.
 */

@property (retain) id representedObject;

/*!
 @property sender
 @abstract the sender of the message.
 @discussion this property is taken from @link //maildelivery_ref/occ/data/Part/headers headers @/link. Can be an instance of <tt>NSString</tt> or an instance of <tt>MessageAddressee</tt> (recommended). 
 */

@property (readonly) id /*<MessageAddressee>*/ sender;

/*!
 @property subject
 @abstract the subject of the message.
 @discussion this property is taken from @link //maildelivery_ref/occ/data/Part/headers headers @/link.
 */

@property (readonly) NSString *subject;

/*!
 @property replyTo
 @abstract the \@"Reply-To" header of the message.
 @discussion Taken from @link //maildelivery_ref/occ/data/Part/headers headers @/link. This property returns an array of NSString instances, but you can provide instances of MessageAddressee within the message @link //maildelivery_ref/occ/data/Part/headers headers @/link.
 */

@property (readonly) NSArray *replyTo;

/*!
 @property toRecipients
 @abstract the \@"To" recipients of the message.
 @discussion Taken from @link //maildelivery_ref/occ/data/Part/headers headers @/link. This property returns an array of NSString instances, but you can provide instances of MessageAddressee within the message @link //maildelivery_ref/occ/data/Part/headers headers @/link.
 */

@property (readonly) NSArray *toRecipients;

/*!
 @property ccRecipients
 @abstract the \@"Cc" recipients of the message.
 @discussion Taken from @link //maildelivery_ref/occ/data/Part/headers headers @/link. This property returns an array of NSString instances, but you can provide instances of MessageAddressee within the message @link //maildelivery_ref/occ/data/Part/headers headers @/link.
 */

@property (readonly) NSArray *ccRecipients;

/*!
 @property bccRecipients
 @abstract the \@"Bcc" recipients of the message.
 @discussion Taken from @link //maildelivery_ref/occ/data/Part/headers headers @/link. This property returns an array of NSString instances, but you can provide instances of MessageAddressee within the message @link //maildelivery_ref/occ/data/Part/headers headers @/link.
 */

@property (readonly) NSArray *bccRecipients;  

/*!
 @property recipients
 @abstract An array of NSString instances, the sum of all the recipients.
 */

@property (readonly) NSArray *recipients;

/*!
 @property parts
 @abstract the parts of the message.
 @discussion the message <tt>source</tt> is created based on this property, you don't have to deal with message parts but you can provide them if you want (recommended, specially if you use a WebView in your application), if you do so, you should also provide your own message @link source source @/link.
 */

@property (retain) NSArray *parts;

/*!
 @property source
 @abstract the raw source of the message.
 @discussion The row source of the message, as is send to the server. Uses a lazy getter just in case you don't provide one.
 */

@property (copy) NSString *source;

/*!
 @property attachments
 @abstract the attachments of the message.
 @discussion An array of <tt>NSTextAttachment</tt> instances the represents the attachments of the message, this property is taken from @link //maildelivery_ref/occ/data/Part/content content @/link. In the case of a <tt>Message</tt> instance a <tt>NSAttributedString</tt>. Uses a lazy getter just in case you don't provide one.
 */

@property (copy) NSArray *attachments;

/*!
 @property identifier
 @abstract the unique identifier of the message.
 */

@property (readonly, copy) NSString *identifier;

/*!
 @property creationDate
 @abstract ...
 */

@property (readonly, retain) NSDate *creationDate;

/*!
 @property dateSent
 @abstract ...
 */

@property (retain) NSDate *dateSent;

/*!
 @property encoding
 @abstract the string encoding of the message. Default is NSASCIIStringEncoding.
 */

@property NSStringEncoding encoding;

/*!
 @property priority
 @abstract priority of the message.
 */

@property NSInteger priority;

/*!
 @property relatedBoundary
 @abstract .
 */

@property (readonly) NSString *relatedBoundary;

@end